home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Snippets / IconShow / IconShow++ ƒ / SITable.cp < prev    next >
Encoding:
Text File  |  1994-03-14  |  1.6 KB  |  62 lines  |  [TEXT/KAHL]

  1. /*  
  2.     Copyright © General Consulting & Research Inc. 1993-1994 All rights reserved.
  3.       Author:     Peter H. Teeson 
  4.     CIS:        72647,3674
  5.     AppleLink:    CDA0197
  6.       Date:        1 June 1993 
  7.     Path:IconShow++ ƒ:SITable.cp
  8.        
  9.        This is the C++ Class implementation for the ShowINIT table.    
  10.  
  11.  */
  12.  
  13. #include <SITable.h>
  14. extern unsigned short myScreenWidth,myScreenDepth;
  15. /* Public members */
  16. SITable::SITable(){
  17.     sTable=(unsigned short*)(0x910+32-8);            // CurrAppName+32-8 
  18.     sz=4;                                            // there are only 4 entries    
  19.     if (CheckSum(sTable[hloc]) != sTable[hcheck])    // first INIT means Reset
  20.         { sTable[vloc] = myScreenDepth;                // will be decremented by Reset
  21.           Reset();
  22.         }
  23. }                    
  24.  
  25. SITable::~SITable(){}
  26.  
  27. unsigned short& SITable::operator[](int index){
  28.     if (index<0 || sz<=index)
  29.         { return sTable[0]; }            // should signal a range error *******
  30.     else
  31.         return sTable[index];
  32. }    
  33.  
  34. void SITable::CheckRHEdge(SITable& x){
  35.     /*
  36.      * if we will be off right hand edge of the screen move up
  37.      * one row and reset horizontal location to first position.
  38.      */     
  39.     if ( x.sTable[hloc]>myScreenWidth-IconWidth)
  40.         Reset();
  41. }
  42.  
  43. void SITable::NextLoc(SITable& x) {
  44.     /* 
  45.      * compute location of next icon
  46.      */
  47.      x.sTable[hloc] += XOffset;
  48.      x.sTable[hcheck] = CheckSum(x.sTable[hloc]);
  49.      CheckRHEdge(x);
  50. }
  51.  
  52. /* Private members */
  53. void SITable::Reset(){
  54.     /* 
  55.      * Reset horizontal & vertical locations
  56.      * and re-compute the check sums.
  57.      */
  58.     sTable[vloc] -= YOffset;                        // move up one row
  59.     sTable[hloc] = InitialX;                        // init horizontal loc
  60.     sTable[hcheck] = CheckSum(sTable[hloc]);        // recompute
  61.     sTable[vcheck] = CheckSum(sTable[vloc]);
  62. }